//
//  VerticalViewController.m
//  LBLoopScrollView
//
//  Created by LINAICAI on 2017/6/16.
//  Copyright © 2017年 LINAICAI. All rights reserved.
//

#import "VerticalViewController.h"
#import "LBLoopScrollView.h"
@interface VerticalViewController ()
@property(nonatomic , strong)LBLoopScrollView *upAdView;
@property(nonatomic , strong)LBLoopScrollView *downAdView;
@end

@implementation VerticalViewController
- (void)dealloc{
    self.upAdView = nil;
    self.downAdView = nil;
}
- (LBLoopScrollView *)upAdView{
    if (!_upAdView) {
        LBLoopScrollView *view = [[LBLoopScrollView alloc]initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, self.view.bounds.size.width*9/16) images:@[@"https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=1708877790,1437461839&fm=80&w=179&h=119&img.JPEG",
                                                                                                                                                                  @"http://img1.gtimg.com/news/pics/hv1/247/36/2217/144169852.jpg",
                                                                                                                                                                  @"http://img.jiankang.com/temp/2017/06/14/14974282237125.jpg",
                                                                                                                                                                  @"http://img0.utuku.china.com/640x0/news/20170613/19e23c3b-22ca-4001-9c95-7a8218629cf2.jpg"
                                                                                                                                                                  ]];

        view.backgroundColor = [UIColor whiteColor];
        view.automatically = YES;
        view.direction = LBLoopScrollViewDirectionUp;
        view.showPageControl = YES;
        view.timeInterval = 1.0;
        _upAdView = view;
    }
    return _upAdView;
}
- (LBLoopScrollView *)downAdView{
    if (!_downAdView) {
        LBLoopScrollView *view = [[LBLoopScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.width*9/16) images:@[@"https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=1708877790,1437461839&fm=80&w=179&h=119&img.JPEG",
                                                                                                                                                                 @"http://img1.gtimg.com/news/pics/hv1/247/36/2217/144169852.jpg",
                                                                                                                                                                 @"http://img.jiankang.com/temp/2017/06/14/14974282237125.jpg",
                                                                                                                                                                 @"http://img0.utuku.china.com/640x0/news/20170613/19e23c3b-22ca-4001-9c95-7a8218629cf2.jpg"
                                                                                                                                                                 ]];

        view.backgroundColor = [UIColor whiteColor];
        view.automatically = YES;
        view.direction = LBLoopScrollViewDirectionDown;
        view.showPageControl = YES;
        view.timeInterval = 1.0;
        _downAdView = view;
    }
    return _downAdView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.edgesForExtendedLayout = UIRectEdgeAll;
    [self.navigationController.navigationBar setBackgroundColor:[UIColor whiteColor]];
    
    
    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    [tableView setDelegate:(id<UITableViewDelegate> _Nullable)self];
    [tableView setDataSource:(id<UITableViewDataSource> _Nullable)self];
    tableView.tableHeaderView = self.upAdView;
    tableView.tableFooterView = self.downAdView;
    [self.view addSubview:tableView];
    // Do any additional setup after loading the view.
}
//轮播组件点击回调
- (void)LBLoopScrollViewDidClickWithIndex:(NSInteger)index{
    NSLog(@"点击了广告:%ld",(long)index);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identity"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"identity"];
    }
    cell.textLabel.text = @"分割线";
    return cell;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
